package com.szholly.plug.safe.entity.workday;

import java.util.HashMap;

import org.springframework.stereotype.Component;

import com.szholly.utils.spring.SpringBeanFactory;
import com.szholly.data.general.Field;
import com.szholly.data.general.GlobalDataType;
import com.szholly.data.general.InterceptorTableBase;
import com.szholly.data.general.metadata.IBaseTable;

/**
 * 节假日日期表
 */
@Component("WORKTIME_HOLIDAYS")
public class HolidaysService  extends InterceptorTableBase implements IBaseTable {

	public final static String TABLE_NAME = "WORKTIME_HOLIDAYS";

	/**
	 * 获取单例对象
	 */
	public static HolidaysService getSingleRef() {
		return (HolidaysService) SpringBeanFactory.getBean("WORKTIME_HOLIDAYS");
	}

	@Override
	public String getMetadataTableName() {
		return TABLE_NAME;
	}

	@Override
	public String getMetadataTableAliasName() {
		return "节假日日期表";
	}

	private HashMap<String, Field> fields;

	@Override
	protected HashMap<String, Field> fields() {
		if (fields == null) {
			fields = new HashMap<String, Field>();

			Field itemField = new Field();
			
			itemField = new Field();
			itemField.setFieldName(HolidaysEntity.FIELD_GUID);
			itemField.setDataType(GlobalDataType.String);
			itemField.setFieldID(1);
			itemField.setFieldAliasName("主键ID");
			itemField.setIsKey(true);
			itemField.setCanShow(true);
			fields.put(itemField.getFieldName().toUpperCase().trim(), itemField);

			itemField = new Field();
			itemField.setFieldName(HolidaysEntity.FIELD_C_TYPE);
			itemField.setDataType(GlobalDataType.String);
			itemField.setFieldID(2);
			itemField.setFieldAliasName("日期类型");
			itemField.setCanShow(true);
			itemField.setAllowNull(true);
			fields.put(itemField.getFieldName().toUpperCase().trim(), itemField);

			itemField = new Field();
			itemField.setFieldName(HolidaysEntity.FIELD_HDATE);
			itemField.setDataType(GlobalDataType.Date);
			itemField.setFieldID(3);
			itemField.setFieldAliasName("日期");
			itemField.setCanShow(true);
			itemField.setAllowNull(true);
			fields.put(itemField.getFieldName().toUpperCase().trim(), itemField);

			itemField = new Field();
			itemField.setFieldName(HolidaysEntity.FIELD_YEAR);
			itemField.setDataType(GlobalDataType.String);
			itemField.setFieldID(4);
			itemField.setFieldAliasName("年份");
			itemField.setCanShow(true);
			itemField.setAllowNull(true);
			fields.put(itemField.getFieldName().toUpperCase().trim(), itemField);

		}
		return fields;
	}

	/**
	 * 表分组信息
	 */
	@Override
	public String getTableGroup() {
		return "系统管理";
	}

	@Override
	public String getIDFieldName() {
		return HolidaysEntity.FIELD_GUID;
	}
	
	@Override
	public String getGUIDFieldName(){
		return HolidaysEntity.FIELD_GUID;
	}

}
